|
|
|
|
|
|
|
In this routine, you see a lot of calls to the KeySave() method. Also, notice the use of named arguments. |
|
|
|
|
|
|
|
|
The KeySave() Method in the INI Class |
|
|
|
|
|
|
|
|
The KeySave() method is very similar to the KeyGet() method in that it receives optional arguments and assigns them to the appropriate module-level variables. Then, the WritePrivateProfileString() function is called. Heres the code: |
|
|
|
 |
|
|
|
|
Public Sub KeySave(Optional strKeyValue As String = "NA", _
Optional strSection As String = "NA", _
Optional strKeyName As String = "NA")
Dim lngRet As Long
' Fill in properties
If strSection <> "NA" Then
mstrSection = strSection
End If
If strKeyName <> "NA" Then
mstrKeyName = strKeyName
End If
If strKeyValue <> "NA" Then
mstrKeyValue = strKeyValue
End If
lngRet = WritePrivateProfileString(mstrSection, _
mstrKeyName, _
mstrKeyValue, _
mstrConfigName) End Sub |
|
|
|
|
|
|
|
|
Using the INI Class to Get a Section's Values |
|
|
|
|
|
|
|
|
Sometimes you might want to retrieve all the key names and key values from one section in an INI file. In this case, you can call the SectionGet() method in the INI class to have it return a Variant array of all the KeyName=KeyValue pairs of data. Heres the code: |
|
|
|
 |
|
|
|
|
Private Sub cmdAllSettings_Click()
Dim oIni As INI
Dim astrKeys As Variant
Dim intLoop As Integer |
|
|
|
|
|